<?php

namespace app\api\controller;

use think\Request;
use \think\Exception;
use think\Log;
use Carbon\Carbon;
use app\api\model\Users;
use services\SmsFactory;

class Share extends Api
{
    protected $beforeActionList = [
      
    ];

	public function _initialize()
    {
        $this->model['search']  = new Users;              
    }

    public function getIndex()
    {
        $this->setData(model('user/Calendar')->getShareToRentLine(21, '2017-01-21', '2017-01-22'));
    	//\think\Queue::push('common/Job@pay', $data = '1', 'order');
        // queue('common/Job@pay', $data = '2', $delay = 0, $queue = 'order');
        // queue('common/Job@order', $data = '3', $delay = 0, $queue = 'order');
    	return $this->send();
    	die;
    	halt(SmsFactory::init('MailAliyun')->sendJm('有用户要加盟啦！','9714928@qq.com'));
    }

    public function getLists()
    {
    	try {
    		$sharelist = model('Orders')->all();
    		$this->setData($this->getTokenUserInfo());
    		return $this->send();
    	} catch (Exception $e) {
    		throw new Exception($e->getMessage(), $e->getCode());		
    	} catch (\Exception $e) {
    		Log::record(['code' => $e->getCode(), 'mes' => $e->getMessage()]);
    		throw new Exception("其他未知错误", -888);    		
    	}
    }

    /**
     * 搜索
     * @return [type] [description]
     */
    public function getSearch()
    {
    	try {
    		$s_date = $this->request->get('s_date');
    		$e_date = $this->request->get('e_date');
    		$region = $this->request->get('region');

    		$lsits = $this->model['search']->all();
    		$this->setData($lsits);
    		return $this->send();

    	} catch (Exception $e) {
    		throw new Exception($e->getMessage(), $e->getCode());
    	} catch (\Exception $e) {
    		Log::record(['code' => $e->getCode(), 'mes' => $e->getMessage()]);
    		throw new Exception("其他未知错误", -888);    		
    	}
    }
}
